<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css"/>
</head>

<BODY style="background-color:#E3F1FD" onLoad="setdepart('proposalDept');">
<form method="post" name="myform">
  <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
	    <td width="100" height="40"  >
	    <strong>查找：</strong>
	    </td>
	    <td class="t_l">
	    <input id="proposalDept" name="proposalDept" type="text" class="inout01"  onkeyup="setdepart('proposalDept');">
	       </td>
	       </tr>
  </table>
  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" height="25" align="center" background="images/maintlbg01.gif" class="tablezwz"><strong>可选</strong></td>
    </tr>
    <tr>
      <td width="100%" align="center" bgcolor="#E3F1FD">
		<select style="width:98%; height:300px; border:1px solid #898F94;" multiple name="list1" size="12" ondblclick="check();">
	  </select></td>
    </tr>
  </table>
  <table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <input type="hidden" name="usersId" value=""/>
      <input type="hidden" name="usersName" value=""/>
      <td height="50" align="center"><button class="but_bg" onClick="check();">确定</button></td>
      <td height="50" align="center"><button class="but_bg" onClick="javascript:window.close();">取消</button></td>
    </tr>
  </table>
</form>

<script language="JavaScript">
var count = 0;

function setdepart(proposalDept){
   var s_proposalDept = document.getElementById(proposalDept).value;;
	var list1 = document.getElementById("list1");
	$.ajax({
			type:"POST",
			url:"${ctx}/proposal/proposal!findProposalDept.action",
			data:"s_proposalDept=" + s_proposalDept + "&time=" + new Date().getTime(),
			dataType:"json",
			success:function (json){
				var proposalDepts = json.proposalDepts;
				cleacSelect('list1');
				for(var i = 0;i < proposalDepts.length;i++){
					list1.options[i] = new Option(proposalDepts[i].proposalDeptName,proposalDepts[i].proposalDeptId);
				}
			},
			error:function (){
				alert("系统异常!");
			}
		});
}

function cleacSelect(objID){
	var selectObj = document.getElementById(objID);
	var length = selectObj.options.length;
	for(var i = 0;i < length;i++){
		selectObj.options[0] = null;
	}
}

function check(){

var e1 = document.getElementById('list1');
   for(var i=0;i<e1.options.length;i++){
		if(e1.options[i].selected){
			var e = e1.options[i];
			var array = [e.value, e.text];
			window.returnValue = array;
	    	window.close();
		}
	}
}
</script>
</BODY>
</HTML>
